#include <stdio.h>

//https://www.nowcoder.com/practice/e0e4f81dcd55408a8973f8033bbeb1d2?tpId=107&&tqId=33376&rp=1&ru=/ta/beginner-programmers&qru=/ta/beginner-programmers/question-ranking

int main() {
    int n = 0;
    int num = 0;
    int min = 0;
    int max = 0;
    scanf("%d", &n);
    scanf("%d", &min);
    max = min;
    for (int i = 1; i < n; i++) {
        scanf("%d", &num);
        if (min > num) {
            min = num;
        } else if(max < num) {
            max = num;
        }
    }
    printf("%d", max - min);
    return 0;
}